<%@page import="java.util.List"%>
<%@page import="model.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	User u = new User();
	//	kiem tra có phải admin không nếu khong thi redirect home
	if (!u.isAdmin((String) session.getAttribute("lv"))) {
		response.sendRedirect("../index.jsp");
	}
	National national = new National();
	Categories categories = new Categories();
	Flevel flevel = new Flevel();
	int sp = categories.getSizeDB();
	int pt = 0;
	int nids = 0;
	int cids = 0;
	int ls = 0;
	/* get info where error */
	String nvn = ((String) request.getAttribute("nvn"));
	String nen = ((String) request.getAttribute("nen"));
	String nid = (String) request.getAttribute("nid");
	String cid = (String) request.getAttribute("cid");
	String ft = ((String) request.getAttribute("ft"));
	String q = ((String) request.getAttribute("q"));
	String dr = ((String) request.getAttribute("dr"));
	String pd = ((String) request.getAttribute("pd"));
	String it = ((String) request.getAttribute("it"));
	String l = ((String) request.getAttribute("l"));
	//error response
	String en = ((String) request.getAttribute("en"));
	if (nid != null) {nids = Integer.parseInt(nid);}
	
	if (l!= null) {ls = Integer.parseInt(l);}
	if (cid != null) {cids = Integer.parseInt(cid);
}
	;
	nvn = (nvn == null) ? "" : nvn;
	nen = (nen == null) ? "" : nen;
	ft = (ft == null) ? "" : ft;
	q = (q == null) ? "" : q;
	dr = (dr == null) ? "" : dr;
	pd = (pd == null) ? "" : pd;
	it = (it == null) ? "" : it;
	en = (en == null) ? "*" : en;
	int[] Anid = national.getNID("");
	int[] Acid = categories.getCID("");
%>
<title>MYFILM - Add Film</title>
<form action="AddFilm" onsubmit="return validate(this)" method="post">
	<fieldset>
		<legend>Add FILM</legend>
		<div>
			<label for="n">National: <span class="required"><%=en%></span></label>
			<select name="n" tabindex='3'>
				<%
					for (int i : Anid) {
				%>
				<option value="<%=i%>" <%=(i == nids) ? "selected='selected'" : ""%>><%=national.getNational(i).getN_name()%></option>
				<%
					}
				%>
			</select>
		</div>
		<div>
			<label for="pt">Category : <span class="required">*</span></label> <select
				name="pt" tabindex='3'>
				<%
					for (int i : Acid) {
				%>
				<option value="<%=i%>" <%=(i == cids) ? "selected='selected'" : ""%>><%=categories.getCatByID(i).getCat_name()%></option>
				<%
					}
				%>
			</select>
		</div>
		<div>
			<label for="l">Level : <span class="required">*</span></label> 
			<select
				name="l" tabindex='3'>
				<%
					for (int i = 1; i<=10 ; i++) {
				%>
				<option value="<%=i%>" <%=(i == ls) ? "selected='selected'" : ""%>><%=i%></option>
				<%
					}
				%>
			</select>
		</div>
		<div>
			<label for="nvn">Movie NameVN: <span class="required"><%=en%></span></label>
			<input type="text" name="nvn" value="<%=nvn%>" size="20"
				maxlength="150" tabindex="1" />
		</div>
		<div>
			<label for="nen">Movie NameEN:</label> 
			<input type="text" name="nen" value="<%=nen%>" size="20" maxlength="150" tabindex="1" />
		</div>
		<div>
			<label for="ft">Lenght :</label> 
			<input type="text" name="ft" value="<%=ft%>" size="20" maxlength="150" tabindex="1" />
		</div>
		<div>
			<label for="q">Quality :</label> 
			<input type="text" name="q" value="<%=q%>" size="20" maxlength="150" tabindex="1" />
		</div>
		<div>
			<label for="dr">Director :</label> 
			<input type="text" name="dr" value="<%=dr%>" size="20" maxlength="150" tabindex="1" />
		</div>
		<div>
			<label for="pd">Production Date :</label> 
			<input type="text" name="pd" value="<%=pd%>" size="20" maxlength="150" tabindex="1" />
		</div>
		<div>
			<label for="it">Intro :</label> 
			<textarea name="it" rows="1" cols="60" ><%=it %></textarea>
		</div>
		
		<input type="hidden" name="uid"
			value="<%=session.getAttribute("uid")%>">
	</fieldset>
	<p>
		<input type="submit" name="submit" value="Add Film" />
	</p>
</form>